<template>
    <div class="location">
    
        <el-breadcrumb separator="/">
            <el-breadcrumb-item>您现在的位置：</el-breadcrumb-item>
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item v-for="(item,index) in locations"
                                key="index"
                                :to="{path:item.url}">{{item.text}}</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
</template>

<script>
export default {
    data() {
        return {
            locations: [

            ]
        }
    },
    created() {
        let item = {};
        if (this.$route.path == '/about') {
            item = {
                text: '关于我们',
                url: '/about'
            }
        } else if (this.$route.path == '/contact') {
            item = {
                text: '联系我们',
                url: '/contact'
            }
        } else if (this.$route.path == '/honours') {
            item = {
                text: '荣誉资质',
                url: '/honours'
            }
        } else if (this.$route.path == '/hospitals') {
            item = {
                text: '权威医院',
                url: '/hospitals'
            }
        } else if (this.$route.params.processCategory == '1') {
            item = {
                text: '海外医疗咨询与服务',
                url: '/process/1/'
            }
        } else if (this.$route.params.processCategory == '2') {
            item = {
                text: '海外专家远程会诊服务',
                url: '/process/2/'
            }
        } else if (this.$route.params.processCategory == '3') {
            item = {
                text: '其他服务',
                url: '/process/3/'
            }
        } else if (this.$route.params.category == '1') {
            item = {
                text: '公司新闻',
                url: '/news/1/'
            }
        } else if (this.$route.params.category == '2') {
            item = {
                text: '医学前沿',
                url: '/news/2/'
            }
        }
        this.locations.splice(0, 1, item)
    },
    watch: {
        $route() {
            let item = {};
            if (this.$route.path == '/about') {
                item = {
                    text: '关于我们',
                    url: '/about'
                }
            } else if (this.$route.path == '/contact') {
                item = {
                    text: '联系我们',
                    url: '/contact'
                }
            } else if (this.$route.path == '/honours') {
                item = {
                    text: '荣誉资质',
                    url: '/honours'
                }
            } else if (this.$route.path == '/hospitals') {
                item = {
                    text: '权威医院',
                    url: '/hospitals'
                }
            } else if (this.$route.params.processCategory == '1') {
                item = {
                    text: '海外医疗咨询与服务',
                    url: '/process/1/'
                }
            } else if (this.$route.params.processCategory == '2') {
                item = {
                    text: '海外专家远程会诊服务',
                    url: '/process/2/'
                }
            } else if (this.$route.params.processCategory == '3') {
                item = {
                    text: '其他服务',
                    url: '/process/3/'
                }
            } else if (this.$route.params.category == '1') {
                item = {
                    text: '公司新闻',
                    url: '/news/1/'
                }
            } else if (this.$route.params.category == '2') {
                item = {
                    text: '医学前沿',
                    url: '/news/2/'
                }
            }
            this.locations.splice(0, 1, item)
        }
    },
}
</script>

<style lang="less">
.location {
    width: 1266px;
    margin: 0 auto;
}
</style>